package cn.xz.nearby.controller;

import cn.xz.nearby.common.AjaxResult;
import cn.xz.nearby.service.IUserLocationService;
import cn.xz.nearby.vo.UserLocationVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/nearbyUser")
public class UserLocationController {
    @Autowired
    private IUserLocationService userLocationService;

    @PostMapping("/insert")
    public AjaxResult insert(@RequestBody UserLocationVo userLocationVo){
        userLocationService.add(userLocationVo);
        return AjaxResult.me();
    }
    @PostMapping("/update")
    public AjaxResult update(@RequestBody UserLocationVo userLocationVo){
        userLocationService.update(userLocationVo);
        return AjaxResult.me();
    }
    @PostMapping("/queryOne/{id}")
    public AjaxResult queryOne(@PathVariable("/id")String id){

        return AjaxResult.me().setData(userLocationService.queryOne(id));
    }

    @PostMapping("/getNearByUser")
    public AjaxResult getNearByUser(@RequestBody UserLocationVo userLocationVo){
        return AjaxResult.me().setData(userLocationService.getNearByUser(userLocationVo));
    }

}
